////////////////////////////////////////////////////////////
// Workfile : Reader.h
// Author : Andreas Lehner
// Date : 5.11.2012
// Description : reads a given file (address or person) INTERFACE
// Remarks : 0
// Revision : 1
////////////////////////////////////////////////////////////
#ifndef READER_H
#define READER_H

#include "IRead.h"
#include <string>

class Reader {
public:
	//read file -> delegates to function reading address-file or person-file (template method)
	void ReadFile(std::string const& filename, IRead *read);
protected:
	//abstract method -> reads addresses or persons
	virtual void DoRead(std::string const& line, IRead *read) = 0;
	//function to check if string is a number
	bool isNumber(std::string const& str) const;
	//read a word of a string
	std::string readWord(std::string::const_iterator & start, std::string::const_iterator const& end) const;
	//read a number of a string
	size_t readNumber(std::string::const_iterator & start, std::string::const_iterator const& end) const;
};

#endif